package com.online.service_base.exceptionHandler;

import com.online.common_utils.ResultJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultJson errorHandler(Exception e){
        log.error(e.getMessage());
        e.printStackTrace();
        return ResultJson.error().message("执行了全局异常处理");
    }
}
